﻿/*
BF3Rcon.NET, provides a .NET implementation of BF3's RCON interface.
Copyright (C) 2011 Timi

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

You can contact us at http://bf3rcon.codeplex.com/.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Collections.ObjectModel;

namespace System.Net.Battlefield3
{
    /// <summary>
    /// Provides data for the <see cref="RconClient.RoundOver"/> event.
    /// </summary>
    [Serializable]
    public class RoundOverEventArgs : EventArgs
    {
        //NOTE: the members will be populated in RconClient because not all of the data is received at the same time
        //these members are for this kind of check
        internal bool RoundOver;
        internal bool RoundOverPlayers;
        internal bool RoundOverTeamScores;

        /// <summary>
        /// Gets the ID of the team that won the round.
        /// </summary>
        /// <value>The ID of the team that won the round.</value>
        public int WinningTeam { get; internal set; }

        /// <summary>
        /// Gets the scores of each team ID. This uses a one-based index because team IDs start at one.
        /// </summary>
        /// <value>
        /// A <see cref="ReadOnlyCollection{T}" /> containing the team scores, where index 0 is not used (-1) and the
        /// other indices are the team IDs. Also returns null if the request failed.
        /// </value>
        public ReadOnlyCollection<int> TeamScores { get; internal set; }

        /// <summary>
        /// Gets the score required for the round to end.
        /// </summary>
        /// <value>The score required for the round to end.</value>
        public int TargetScore { get; internal set; }

        /// <summary>
        /// Gets the <see cref="Player">Players</see> in the server, which contain the final values of the round.
        /// </summary>
        /// <value>The <see cref="Player">Players</see> in the server.</value>
        public PlayerCollection Players { get; internal set; }

        //internal RoundOverEventArgs(int winningTeam, ReadOnlyCollection<int> teamScores, int targetScore, PlayerCollection players)
        //{
        //    WinningTeam = winningTeam;
        //    TeamScores = teamScores;
        //    TargetScore = targetScore;
        //    Players = players;
        //}

        //copying is done because after the event is raised, the eventargs will be reset to a new object
        internal RoundOverEventArgs(RoundOverEventArgs e)
        {
            WinningTeam = e.WinningTeam;
            TeamScores = e.TeamScores;
            TargetScore = e.TargetScore;
            Players = e.Players;
        }

        internal RoundOverEventArgs()
        {

        }
    }
}
